package com.yl.myapplication.slice;

import com.yl.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.TextField;

public class HomeAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_home);
        TextField et = (TextField) findComponentById(ResourceTable.Id_et);

        if (intent != null) {
            String data = intent.getStringParam("data");
            et.setText(data);
        }

        Button btn = (Button) findComponentById(ResourceTable.Id_btn);
        btn.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                intent.setParam("pwd", "勇敢去追!");
                setResult(intent);
                terminate();//结束当前界面
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
